/**
 * Created by meiguizhinian on 2018/7/20
 * Copyright © 2018 lixiaolong. All rights reserved.
 */

//TODO：等待完成
if (!cc.sys.isNative) {
	ccui.Slider.prototype._maxPercent = 100;
	ccui.Slider.prototype.setMaxPercent = function (percent) {
		this._maxPercent = percent;
	};
	ccui.Slider.prototype.setPercent = function(percent) {
		if (percent > this._maxPercent)
			percent = this._maxPercent;
		if (percent < 0)
			percent = 0;
		this._percent = percent;
		let res = percent / 100.0;
		let dis = this._barLength * res;
		this._slidBallRenderer.setPosition(dis, this._contentSize.height / 2);
		if (this._scale9Enabled)
			this._progressBarRenderer.setPreferredSize(cc.size(dis, this._contentSize.height));
		else {
			let spriteRenderer = this._progressBarRenderer;
			let rect = spriteRenderer.getTextureRect();
			spriteRenderer.setTextureRect(
				cc.rect(rect.x, rect.y, dis / spriteRenderer._scaleX, rect.height),
				spriteRenderer.isTextureRectRotated()
			);
		}
	};
}